﻿using System;
using System.Windows.Forms;

namespace GameListEditor
{
    ///-------------------------------------------------------------------------------------------------
    /// <summary> Form used to display database properties. </summary>
    ///-------------------------------------------------------------------------------------------------
    public partial class FormProperties : Form
    {
        /// <summary> Initializes a new instance of the <see cref="T:System.Windows.Forms.Form" /> class. </summary>
        public FormProperties()
        {
            InitializeComponent();
        }

        ///-------------------------------------------------------------------------------------------------
        /// <summary> Sets game count. </summary>
        /// <param name="value"> The value. </param>
        ///-------------------------------------------------------------------------------------------------
        public void SetGameCount(int value)
        {
            if (LBL_GameCountValue.InvokeRequired)
                LBL_GameCountValue.BeginInvoke(new MethodInvoker(delegate { SetGameCount(value); }));
            else
                LBL_GameCountValue.Text = String.Format("{0:#,##0}", value);
        }

        ///-------------------------------------------------------------------------------------------------
        /// <summary> Sets database size in bytes. </summary>
        /// <param name="value"> The value. </param>
        ///-------------------------------------------------------------------------------------------------
        public void SetDbSizeInBytes(Int64 value)
        {
            if (LBL_DbSizeValue.InvokeRequired)
                LBL_DbSizeValue.BeginInvoke(new MethodInvoker(delegate { SetDbSizeInBytes(value); }));
            else
                LBL_DbSizeValue.Text = String.Format("{0:#,##0} KB", (value / 1024));
        }

        ///-------------------------------------------------------------------------------------------------
        /// <summary> Sets database last modified time. </summary>
        /// <param name="value"> The last time db was modified in UTC. </param>
        ///-------------------------------------------------------------------------------------------------
        public void SetDbLastModifiedTimeUTC(DateTime? value)
        {
            if (LBL_DbLastModifiedValue.InvokeRequired)
                LBL_DbLastModifiedValue.BeginInvoke(new MethodInvoker(delegate { SetDbLastModifiedTimeUTC(value); }));
            else if (value.HasValue)
                LBL_DbLastModifiedValue.Text = value.Value.ToLocalTime().ToString();
            else
                LBL_DbLastModifiedValue.Text = "Unavailable";
        }
    }
}
